#pragma once

#include <QString>
#include <QList>
#include <QColor>
#include <QSharedPointer>
#include <QMetaType>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonValue>
#include <QMetaType>

namespace jdt_mes
{
	enum DeviceCommType
	{
		CCT_INVALID,
		CCT_COM,
		CCT_TCP_IP,
		CCT_MODBUS_TCP,
		CCT_MC_TCP,
		CCT_ALL
	};

	enum DeviceConnState
	{
		UnconnectedState,
		ConnectingState,
		ConnectedState,
		ClosingState,
		ConnectTimeOut
	};

	struct SerialInfo
	{
		QString comPort;
		unsigned int baudRate;
		unsigned int dataBits;
		unsigned int parity;
		unsigned int stopBits;
		unsigned int flowControl;
	};

	struct TcpConnectInfo
	{
		QString ip;
		int port;
	};

	struct DeviceConfig
	{
		QString device_name;
		DeviceCommType comm_type;
		QSharedPointer<SerialInfo> serical_info;
		QSharedPointer<TcpConnectInfo> tcp_info;
	};

	struct SiteConfigInfo
	{
		QString site_id;
		QString site_name;
		QString ini_file_path;
		QVector<QSharedPointer<DeviceConfig>> devices;
	};

#define NORMAL_COLOR 100, 149, 237
#define FAIL_COLOR 236,17,72
#define OK_COLOR 87,191,20
#define WARING_COLOR 247,243,20
#define NG_COLOR 236,17,72

	enum DEVICE_CONN_TYPE
	{
		ASYNC_AND_TIME_OUT, //Qt::QueuedConnection //timeout return
		ASYNC,  //Qt::QueuedConnection
		SYNC_FAQ_WAIT  //Qt::BlockingQueuedConnection
	};
}